use actix_web::{error::ErrorInternalServerError, web, Responder, Result};

use crate::{
    api_add, api_delete, api_edit,
    database::DbPool,
    route::form::category::{CategoryForm, NewCategoryForm},
    service::class,
};

pub fn config_admin_category(cfg: &mut web::ServiceConfig) {
    cfg.service(
        web::scope("/category")
            .route("/add", web::post().to(add_category))
            .route("/edit", web::post().to(edit_category))
            .route("/delete", web::post().to(delete_category)),
    );
}

api_add!(add_category, NewCategoryForm, class::category::add);
api_edit!(edit_category, CategoryForm, class::category::upd);
api_delete!(delete_category, CategoryForm, class::category::del);
